import request from "@/utils/request"

export enum AppUserStatus {
  启用 = 1,
  禁用 = 2,
}

export enum AppUserOrgType {
  是经销商 = 1,
  非经销商 = 2,
}

export interface QueryUserListParams extends PaginationParams {
  telephone?: string
  status?: AppUserStatus
  orgOw?: AppUserOrgType
}

export async function queryUserList(params: QueryUserListParams) {
  return request<AppUser[]>('/app/manager/appUser/list', {
    data: params,
  })
}

export async function queryCityMList(params: QueryUserListParams) {
  return request<AppUser[]>('/app/manager/org/city/list', {
    data: params,
  })
}

export async function getUserDetail(params: {userId: string}) {
  return request<AppUser>('/app/manager/appUser/detail', {
    data: params,
  })
}

export async function delUser(params: {userId: string, status: 1 | 2 | 3}) {
  return request('/app/manager/appUser/upStatus', {
    data: params,
  })
}

export interface Car {
  carBrand: string
  carModel: string
  carPic: string
  carPlate: string
  carSeries: string
  createTime: number
  id: number
  nickname: string
  telephone: string
  vin: string
  vinStatus: number
}
export async function queryCarList(params: {pageNum: number, pageSize: number, userId: number}) {
  return request<Car[]>('/app/manager/carList', {
    data: params,
  })
}

export enum DealRecordInfoType {
  充值 = 1,
  充电消费 = 2,
  退款 = 3,
  企业授信 = 4,
  企业回收 = 5,
  企业付款 = 6,
}
export enum DealRecordStatus {
  已退款 = 1,
  审核中 = 2,
  退款失败 = 3,
  退款中 = 4,
}
export enum DealRefundStatus {
  已退款 = 2,
  审核中 = 1,
  退款失败 = 3,
  退款中 = 4,
}
export interface QueryDealRecordListParams extends PaginationParams {
  telephone?: string
  infoType?: DealRecordInfoType
  /** 开始时间 */
  beginTime?: string
  /** 截止时间 */
  endTime?: string
  userId?: string
}
export interface DealRecord {
  id: number
  createTime: number
  infoType: DealRecordInfoType
  nickname: string
  telephone: string
  status: DealRecordStatus
  /** 金额 */
  totalM: number
}
export async function queryDealRecordList(params: QueryDealRecordListParams) {
  return request<DealRecord[]>('/app/manager/balance/changeList', {
    data: params,
  })
}
